home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / ODBC for Macintosh / ODBC Tools / includes / SQL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-19  |  7.0 KB  |  274 lines  |  [TEXT/MPS ]

  1.  
  2.     /*****************************************************************
  3.      SQL.H - This is the the main include for ODBC Core functions.
  4.     
  5.      preconditions:
  6.       #include "windows.h"
  7.     
  8.      (C) Copyright 1990, 1991 By Microsoft Corp.
  9.     *********************************************************************/
  10.  
  11. #ifndef __SQL
  12. #define __SQL
  13.  
  14. #define FAR
  15. #define NEAR
  16. #define TRUE    1
  17. #define FALSE    0
  18.  
  19.     /* generally useful constants    */
  20.  
  21. #define SQL_NTS                    -3    /* NTS = Null Terminated String        */
  22. #define SQL_SQLSTATE_SIZE        5    /* size of SQLSTATE                    */
  23. #define SQL_MAX_MESSAGE_LENGTH  512    /* message buffer size                */
  24. #define SQL_MAX_DSN_LENGTH        32    /* maximum data source name size    */
  25.  
  26.     /* RETCODEs */
  27.  
  28. #define SQL_ERROR                -1
  29. #define SQL_INVALID_HANDLE        -2
  30. #define SQL_NEED_DATA            99
  31. #define SQL_NO_DATA_FOUND        100
  32. #define SQL_SUCCESS                0
  33. #define SQL_SUCCESS_WITH_INFO    1
  34.  
  35.     /* SQLFreeStmt defines */
  36. #define SQL_CLOSE              0
  37. #define SQL_DROP               1
  38. #define SQL_UNBIND             2
  39. #define SQL_RESET_PARAMS       3
  40.  
  41.     /* SQLSetParam defines */
  42. #define SQL_C_DEFAULT  99
  43.  
  44.     /* SQLTransact defines */
  45. #define SQL_COMMIT    0
  46. #define SQL_ROLLBACK  1
  47.  
  48.     /* Standard SQL datatypes, using ANSI type numbering */
  49. #define SQL_CHAR      1
  50. #define SQL_NUMERIC   2
  51. #define SQL_DECIMAL   3
  52. #define SQL_INTEGER   4
  53. #define SQL_SMALLINT  5
  54. #define SQL_FLOAT     6
  55. #define SQL_REAL      7
  56. #define SQL_DOUBLE    8
  57. #define SQL_VARCHAR  12
  58.  
  59. #define SQL_TYPE_MIN   1
  60. #define SQL_TYPE_NULL  0
  61. #define SQL_TYPE_MAX  12
  62.  
  63.     /* C datatype to SQL datatype mapping    SQL types 
  64.                                          ----------------------- */
  65. #define SQL_C_CHAR    SQL_CHAR       /* CHAR, VARCHAR, DECIMAL, NUMERIC */
  66. #define SQL_C_LONG    SQL_INTEGER    /* INTEGER          */
  67. #define SQL_C_SHORT   SQL_SMALLINT   /* SMALLINT         */
  68. #define SQL_C_FLOAT   SQL_REAL       /* REAL             */
  69. #define SQL_C_DOUBLE  SQL_DOUBLE     /* FLOAT, DOUBLE    */
  70.  
  71.     /* NULL status constants.  These are used in SQLColumns, SQLColAttributes,
  72.     SQLDescribeCol, and SQLSpecialColumns to describe the nullablity of a
  73.     column in a table.  SQL_NULLABLE_UNKNOWN can be returned only by 
  74.     SQLDescribeCol or SQLColAttributes.  It is used when the DBMS's meta-data
  75.     does not contain this info.  */
  76. #define SQL_NO_NULLS         0
  77. #define SQL_NULLABLE         1
  78. #define SQL_NULLABLE_UNKNOWN 2
  79.  
  80.     /* Special length values */
  81. #define SQL_NULL_DATA       -1
  82. #define SQL_DATA_AT_EXEC    -2
  83.  
  84.     /* SQLColAttributes defines */
  85. #define SQL_COLUMN_COUNT            0
  86. #define SQL_COLUMN_NAME             1
  87. #define SQL_COLUMN_TYPE             2
  88. #define SQL_COLUMN_LENGTH           3
  89. #define SQL_COLUMN_PRECISION        4
  90. #define SQL_COLUMN_SCALE            5
  91. #define SQL_COLUMN_DISPLAY_SIZE     6
  92. #define SQL_COLUMN_NULLABLE         7
  93. #define SQL_COLUMN_UNSIGNED         8
  94. #define SQL_COLUMN_MONEY            9
  95. #define SQL_COLUMN_UPDATABLE       10
  96. #define SQL_COLUMN_AUTO_INCREMENT  11
  97. #define SQL_COLUMN_CASE_SENSITIVE  12
  98. #define SQL_COLUMN_SEARCHABLE      13
  99. #define SQL_COLUMN_TYPE_NAME       14
  100.  
  101.     /* SQLColAttributes subdefines for SQL_COLUMN_UPDATABLE */
  102. #define SQL_ATTR_READONLY          0
  103. #define SQL_ATTR_WRITE             1
  104. #define SQL_ATTR_READWRITE_UNKNOWN 2
  105.  
  106.     /* SQLColAttributes subdefines for SQL_COLUMN_SEARCHABLE */
  107.     /* These are also used by SQLGetInfo                     */
  108. #define SQL_UNSEARCHABLE           0
  109. #define SQL_LIKE_ONLY              1
  110. #define SQL_ALL_EXCEPT_LIKE        2
  111. #define SQL_SEARCHABLE             3
  112.  
  113.     /* SQLError defines */
  114. #define SQL_NULL_HENV    0
  115. #define SQL_NULL_HDBC    0
  116. #define SQL_NULL_HSTMT   0
  117.  
  118.     /* environment specific definitions */
  119.  
  120. #define SQL_API pascal
  121.  
  122.     /* SQL portable types for C */
  123.  
  124. typedef unsigned char       UCHAR;
  125. typedef signed char         SCHAR;
  126. typedef long int            SDWORD;
  127. typedef short int           SWORD;
  128. typedef unsigned long int   UDWORD;
  129. typedef unsigned short int  UWORD;
  130. typedef double              SDOUBLE;
  131. typedef long double         LDOUBLE;
  132. typedef float               SFLOAT;
  133.  
  134.     typedef void            *PTR;
  135.     typedef struct ENV        **HENV;
  136.     typedef struct DBC        **HDBC;
  137.     typedef struct STMT        **HSTMT;
  138.     typedef Handle            HANDLE;
  139.     typedef void            VOID;
  140.  
  141.     typedef unsigned short    BOOL;
  142.     typedef unsigned char     BYTE;
  143.     typedef short             WORD;
  144.     typedef long            LONG;
  145.     typedef unsigned long     DWORD;
  146.     typedef short             RETCODE;    // should be OSerr    -    mj
  147.     typedef void             *HWND;
  148.     typedef void            *LPVOID;
  149.     typedef char            *LPSTR;
  150.  
  151.     typedef SQL_API RETCODE (*PFUNC)();
  152.  
  153.  
  154.     /* Core Function Prototypes    */
  155.  
  156. SQL_API RETCODE SQLAllocConnect( HENV henv, HDBC *phdbc );
  157. SQL_API RETCODE SQLAllocEnv( HENV *phenv );
  158. SQL_API RETCODE SQLAllocStmt( HDBC hdbc, HSTMT *phstmt );
  159.  
  160. SQL_API RETCODE SQLBindCol(
  161.     HSTMT       hstmt,
  162.     UWORD       icol,
  163.     SWORD       fCType,
  164.     PTR         rgbValue,
  165.     SDWORD      cbValueMax,
  166.     SDWORD        *pcbValue );
  167.  
  168. SQL_API RETCODE SQLCancel(
  169.     HSTMT       hstmt );
  170.  
  171. SQL_API RETCODE SQLColAttributes(
  172.     HSTMT        hstmt,
  173.     UWORD        icol,
  174.     UWORD        fDescType,
  175.     PTR            rgbDesc,
  176.     SWORD        cbDescMax,
  177.     SWORD        *pcbDesc,
  178.     SDWORD        *pfDesc );
  179.  
  180. SQL_API RETCODE SQLConnect(
  181.     HDBC        hdbc,
  182.     UCHAR        *szDSN,
  183.     SWORD       cbDSN,
  184.     UCHAR        *szUID,
  185.     SWORD       cbUID,
  186.     UCHAR        *szAuthStr,
  187.     SWORD       cbAuthStr);
  188.  
  189. SQL_API RETCODE SQLDescribeCol(
  190.     HSTMT       hstmt,
  191.     UWORD       icol,
  192.     UCHAR  FAR *szColName,
  193.     SWORD       cbColNameMax,
  194.     SWORD  FAR *pcbColName,
  195.     SWORD  FAR *pfSqlType,
  196.     UDWORD FAR *pcbColDef,
  197.     SWORD  FAR *pibScale,
  198.     SWORD  FAR *pfNullable);
  199.  
  200. SQL_API RETCODE SQLDisconnect(
  201.     HDBC        hdbc);
  202.  
  203. SQL_API RETCODE SQLError(
  204.     HENV        henv,
  205.     HDBC        hdbc,
  206.     HSTMT       hstmt,
  207.     UCHAR  FAR *szSqlState,
  208.     SDWORD FAR *pfNativeError,
  209.     UCHAR  FAR *szErrorMsg,
  210.     SWORD       cbErrorMsgMax,
  211.     SWORD  FAR *pcbErrorMsg);
  212.  
  213. SQL_API RETCODE SQLExecDirect(
  214.     HSTMT       hstmt,
  215.     UCHAR  FAR *szSqlStr,
  216.     SDWORD      cbSqlStr);
  217.  
  218. SQL_API RETCODE SQLExecute(
  219.     HSTMT       hstmt);
  220.  
  221. SQL_API RETCODE SQLFetch(
  222.     HSTMT       hstmt);
  223.  
  224. SQL_API RETCODE SQLFreeConnect(
  225.     HDBC        hdbc);
  226.  
  227. SQL_API RETCODE SQLFreeEnv(
  228.     HENV        henv);
  229.  
  230. SQL_API RETCODE SQLFreeStmt(
  231.     HSTMT       hstmt,
  232.     UWORD       fOption);
  233.  
  234. SQL_API RETCODE SQLGetCursorName(
  235.     HSTMT       hstmt,
  236.     UCHAR  FAR *szCursor,
  237.     SWORD       cbCursorMax,
  238.     SWORD  FAR *pcbCursor);
  239.  
  240. SQL_API RETCODE SQLNumResultCols(
  241.     HSTMT       hstmt,
  242.     SWORD  FAR *pccol);
  243.  
  244. SQL_API RETCODE SQLPrepare(
  245.     HSTMT       hstmt,
  246.     UCHAR  FAR *szSqlStr,
  247.     SDWORD      cbSqlStr);
  248.  
  249. SQL_API RETCODE SQLRowCount(
  250.     HSTMT       hstmt,
  251.     SDWORD  FAR *pcrow);
  252.  
  253. SQL_API RETCODE SQLSetCursorName(
  254.     HSTMT       hstmt,
  255.     UCHAR  FAR *szCursor,
  256.     SWORD       cbCursor);
  257.  
  258. SQL_API RETCODE SQLSetParam(
  259.     HSTMT       hstmt,
  260.     UWORD       ipar,
  261.     SWORD       fCType,
  262.     SWORD       fSqlType,
  263.     UDWORD      cbColDef,
  264.     SWORD       ibScale,
  265.     PTR         rgbValue,
  266.     SDWORD  FAR *pcbValue);
  267.  
  268. SQL_API RETCODE SQLTransact(
  269.     HENV        henv,
  270.     HDBC        hdbc,
  271.     UWORD       fType );
  272.  
  273. #endif  /* #ifndef __SQL */
  274.